import React, { PropTypes } from 'react';
import { connect } from 'dva';
import { routerRedux } from 'dva/router';
import { Menu, Breadcrumb, Icon, Collapse, Tabs} from 'antd';
const Panel = Collapse.Panel;
const TabPane = Tabs.TabPane;

import UserList from '../../components/user/UserList';
import UserSearch from '../../components/user/UserSearch';
import UserModal from '../../components/user/UserModal';

function Bill({location, dispatch, user, mask }){
    const {dataSource, loading, total, current, modalVisible, modalType} = user;
    const usersearch = {
        onSearch(){
          dispatch(routerRedux({
              pathname:'user',
              query:{page:1}
          }))
        },
        onAdd(){
          dispatch({
            type: 'mask/showMask',
            content:<span>我是表单增加</span>,
          });
        },
    }
    const userlist = {
      dataSource,
      loading,
      total,
      current,
      onPageChange(page){
        dispatch(routerRedux.push({
          pathname: '/user',
          query: {page},
        }));
      }
    }
    const usermodal = {
      type: modalType,
      visible:modalVisible,
      onOk(data) {
        dispatch({
          type: `user/${modalType}`,
          payload: data,
        });
      },
      onCancel() {
        dispatch({
          type: 'user/hideModal',
        });
      },
    }
    return (
        <div className="normal">
          <UserSearch {...usersearch}/>
          <UserList {...userlist}/>
          <UserModal {...usermodal}/>
        </div>
    )
}

function mapStateToProps({ user }) {
  return { user };
}

export default connect(mapStateToProps)(Bill);
